package org.finesys.common.file.client.local;

import org.finesys.common.file.client.FileTemplate;
import org.finesys.common.file.properties.FileProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.AllArgsConstructor;

/**
 * 本地文件存储
 */
@AllArgsConstructor
@Configuration
public class LocalFileAutoConfiguration {

    private final FileProperties fileProperties;


    @Bean
    @ConditionalOnMissingBean(LocalFileTemplate.class)
    @ConditionalOnProperty(name = "file.local.enable", havingValue = "true", matchIfMissing = true)
    public FileTemplate localFileTemplate() {
        return new LocalFileTemplate(fileProperties);
    }
}
